import 'package:easy_read_comic/controller/app_controller.dart';
import 'package:easy_read_comic/controller/me/download_controller.dart';
import 'package:easy_read_comic/utensil/helps.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:url_launcher/url_launcher_string.dart';

class DownView extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return GetBuilder(
      init: DownloadController(),
      builder: (controller) {
        return Scaffold(
          appBar: AppBar(
            iconTheme: IconThemeData(
              color: Colors.white,
            ),
            title: Text(
              "软件下载",
              style: TextStyle(
                color: Colors.white,
              ),
            ),
            backgroundColor: Theme.of(context).primaryColor,
          ),
          body: Container(
            child: GridView(
              gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
                maxCrossAxisExtent: 200.0, // 每个子项的最大宽度
                mainAxisSpacing: 1, // 主轴（纵向）间距
                crossAxisSpacing: 1, // 交叉轴（横向）间距
                childAspectRatio: 1, // 子项的宽高比
              ),
              children: [
                GestureDetector(
                  child: Container(
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: [
                        Icon(
                          Icons.computer,
                          color: Colors.pink,
                          size: 50,
                        ),
                        Container(
                          child: Text("mac桌面端下载"),
                          padding: EdgeInsets.only(
                            top: 10,
                            bottom: 10,
                          ),
                        ),
                      ],
                    ),
                  ),
                  onTap: () {
                    try_launch_url(
                        AppController().getConfig("mac_download_url"));
                  },
                ),
                GestureDetector(
                  child: Container(
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: [
                        Icon(
                          Icons.computer,
                          color: Colors.blueAccent,
                          size: 50,
                        ),
                        Container(
                          child: Text("windows桌面端下载"),
                          padding: EdgeInsets.only(
                            top: 10,
                            bottom: 10,
                          ),
                        ),
                      ],
                    ),
                  ),
                  onTap: () {
                    try_launch_url(
                        AppController().getConfig("windows_download_url"));
                  },
                ),
                GestureDetector(
                  child: Container(
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: [
                        Icon(
                          Icons.android,
                          color: Colors.red,
                          size: 50,
                        ),
                        Container(
                          child: Text("安卓端下载"),
                          padding: EdgeInsets.only(
                            top: 10,
                            bottom: 10,
                          ),
                        ),
                      ],
                    ),
                  ),
                  onTap: () {
                    try_launch_url(
                        AppController().getConfig("android_download_url"));
                  },
                ),
                GestureDetector(
                  child: Container(
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: [
                        Icon(
                          Icons.phone_iphone,
                          color: Colors.deepOrangeAccent,
                          size: 50,
                        ),
                        Container(
                          child: Text("苹果端下载"),
                          padding: EdgeInsets.only(
                            top: 10,
                            bottom: 10,
                          ),
                        ),
                      ],
                    ),
                  ),
                  onTap: () {
                    try_launch_url(
                        AppController().getConfig("ios_download_url"));
                  },
                ),
              ],
            ),
            padding: EdgeInsets.only(
              top: 100,
            ),
            alignment: Alignment.center,
          ),
        );
      },
    );
  }
}
